package com.jike.jkgame;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.jike.jkgame.data.City;
import com.jike.jkgame.data.MissionManager;

public class CitiesActivity extends Activity {

	private ListView mCitiesLv;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.cities_layout);
		mCitiesLv = (ListView) findViewById(R.id.lv_cities);

		ArrayAdapter<City> adapter = new ArrayAdapter<City>(this,
				android.R.layout.simple_list_item_1, android.R.id.text1,
				MissionManager.get().getCities());
		
		mCitiesLv.setAdapter(adapter);
		
		mCitiesLv.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position,
					long id) {
				setResult(position);
				finish();
			}
			
		});
	}

}
